<?php
/* Smarty version 3.1.31, created on 2019-08-07 00:29:45
  from "/www/wwwroot/phprap/application/admin/view/user/index.html" */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.31',
  'unifunc' => 'content_5d49aaf9ecf5c3_39290720',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '19b8fb2be794799d08111892ef1bf1322aa218ec' => 
    array (
      0 => '/www/wwwroot/phprap/application/admin/view/user/index.html',
      1 => 1564463076,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_5d49aaf9ecf5c3_39290720 (Smarty_Internal_Template $_smarty_tpl) {
if (!is_callable('smarty_function_include_file')) require_once '/www/wwwroot/phprap/application/common/smarty/function.include_file.php';
echo smarty_function_include_file(array('name'=>'public/header','title'=>'用户管理'),$_smarty_tpl);?>


</head>

<body>

<div id="wrapper">

    <!-- Navigation -->
    <?php echo smarty_function_include_file(array('name'=>'public/nav','sidebar'=>'sidebar'),$_smarty_tpl);?>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">用户管理</h1>

                <div class="search">
                    <div class="well">
                    <form class="form-inline" action="<?php echo url();?>
" method="get">
                        <div class="form-group">
                            <label>昵称/账号</label>
                            <input type="text" name="search[name]" class="form-control" placeholder="支持模糊查询" value="<?php echo $_smarty_tpl->tpl_vars['search']->value['name'];?>
">
                        </div>
                        <div class="form-group">
                            <label>注册设备</label>
                            <select class="form-control" name="search[device]">
                                <?php $_smarty_tpl->_assignInScope('devices', \app\user::get_device_list('title'));
?>
                                <option value="">不限</option>
                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['devices']->value, 'device', false, 'k');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['k']->value => $_smarty_tpl->tpl_vars['device']->value) {
?>
                                <option value="<?php echo $_smarty_tpl->tpl_vars['k']->value;?>
" <?php if ($_smarty_tpl->tpl_vars['k']->value == $_smarty_tpl->tpl_vars['search']->value['device']) {?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['device']->value;?>
</option>
                                <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);
?>

                            </select>
                        </div>
                        <button type="submit" class="btn btn-primary">搜索</button>
                    </form>
                </div>

                </div>

            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">

                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>用户昵称</th>
                                    <th>登录账号</th>
                                    <th>注册渠道</th>
                                    <th>创建项目</th>
                                    <th>参与项目</th>
                                    <th>注册地点</th>
                                    <th>状态</th>
                                    <th>注册时间</th>

                                    <th>操作面板</th>
                                </tr>
                                </thead>
                                <tbody>

                                <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['users']->value, 'user');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['user']->value) {
?>
                                <?php $_smarty_tpl->_assignInScope('user_id', $_smarty_tpl->tpl_vars['user']->value['id']);
?>
                                <?php $_smarty_tpl->_assignInScope('device', $_smarty_tpl->tpl_vars['user']->value['device']);
?>
                                <tr>
                                    <td ><?php echo $_smarty_tpl->tpl_vars['user']->value['name'];?>
</td>
                                    <td ><?php echo $_smarty_tpl->tpl_vars['user']->value['email'];?>
</td>
                                    <td ><?php echo \app\user::get_device_list('icon',$_smarty_tpl->tpl_vars['device']->value);?>
</td>
                                    <td ><a href="<?php echo url("admin/project/index");?>
?creater_id=<?php echo $_smarty_tpl->tpl_vars['user_id']->value;?>
" data-toggle="tooltip" title="点击查看具体创建项目"><?php echo \app\user::get_create_project_num($_smarty_tpl->tpl_vars['user_id']->value);?>
</a></td>
                                    <td ><a href="<?php echo url("admin/project/index");?>
?joiner_id=<?php echo $_smarty_tpl->tpl_vars['user_id']->value;?>
" data-toggle="tooltip" title="点击查看具体参与项目"><?php echo \app\user::get_join_project_num($_smarty_tpl->tpl_vars['user_id']->value);?>
</a></td>
                                    <td ><?php echo $_smarty_tpl->tpl_vars['user']->value['address'];?>
</td>
                                    <td >
                                        <?php if ($_smarty_tpl->tpl_vars['user']->value['status']) {?>
                                        <i class="fa fa-check"></i>
                                        <?php } else { ?>
                                        <i class="fa fa-times"></i>
                                        <?php }?>
                                    </td>

                                    <td ><?php echo $_smarty_tpl->tpl_vars['user']->value['add_time'];?>
</td>
                                    <td style="width: 18%;">
                                        <?php if ($_smarty_tpl->tpl_vars['user']->value['status']) {?>
                                        <a type="button" class="btn btn-danger btn-xs js_changeStatusBtn" data-id="<?php echo $_smarty_tpl->tpl_vars['user_id']->value;?>
" data-option="冻结" <?php if ($_smarty_tpl->tpl_vars['user']->value['type'] == 2) {?>disabled<?php }?>>冻结用户</a>
                                        <?php } else { ?>
                                        <a type="button" class="btn btn-success btn-xs js_changeStatusBtn" data-id="<?php echo $_smarty_tpl->tpl_vars['user_id']->value;?>
" data-option="激活" <?php if ($_smarty_tpl->tpl_vars['user']->value['type'] == 2) {?>disabled<?php }?>>激活用户</a>
                                        <?php }?>
                                        <a type="button" class="btn btn-warning btn-xs js_resetPasswordBtn" data-id="<?php echo $_smarty_tpl->tpl_vars['user_id']->value;?>
">重置密码</a>

                                    </td>
                                </tr>
                                <?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);
?>

                                
                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <div class="col-sm-12">
                <?php echo smarty_function_include_file(array('name'=>'public/page'),$_smarty_tpl);?>

            </div>

            <!-- /.col-lg-6 -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->
    <hr>
    <p class="text-center"><?php echo get_config('copyright');?>
</p>
    <?php echo '<script'; ?>
>
        //更改用户状态
        $(".js_changeStatusBtn").click(function(event){

            var userId = $(this).data('id');
            var option = $(this).data('option');

            var url = "<?php echo url('admin/user/change_status');?>
";

            confirm('您确认要'+option+'该用户？', function(){

                $.post(url, { user_id:userId }, function(json){

                    alert(json.msg, 1000, function () {
                        window.location.reload();
                    });

                }, 'json');
            });

        });

        //重置密码
        $(".js_resetPasswordBtn").click(function(){

            var userId = $(this).data('id');

            var url = "<?php echo url('admin/user/reset_password');?>
";

            var defaultPassword = "<?php echo $_smarty_tpl->tpl_vars['default_password']->value;?>
";

            confirm('您确认要将登录密码重置为'+defaultPassword+'?<br>(系统设置里可以修改重置默认密码)', function(){

                $.post(url, { user_id:userId }, function(json){

                    if(json.code == 200){

                        alert(json.msg, 500);

                    }else{

                        alert(json.msg, 2000);

                    }

                }, 'json');
            });

        });
    <?php echo '</script'; ?>
>

    <?php echo smarty_function_include_file(array('name'=>'public/footer'),$_smarty_tpl);?>

<?php }
}
